package moon.core;

import java.util.List;

import moon.core.classdef.AttDec;
import moon.core.classdef.ClassDef;
import moon.core.classdef.FormalArgument;
import moon.core.classdef.Type;
import moon.core.expression.constant.BooleanConstant;
import moon.core.expression.constant.CharConstant;
import moon.core.expression.constant.IntegerConstant;
import moon.core.expression.constant.Nil;
import moon.core.expression.constant.StringConstant;
import moon.core.genericity.FormalPar;
import moon.core.instruction.CodeFragment;

/**
 * Factory to create new elements.
 * 
 * @author <a href="mailto:rmartico@ubu.es">Ra&uacute;l Marticorena</a>
 * @since JavaMoon-2.1.0
 */
public abstract class MoonFactory {

	/**
	 * Creates a formal argument.
	 * 
	 * @param name
	 *            name
	 * @param type
	 *            type
	 * @return formal argument
	 */
	public abstract FormalArgument createFormalArgument(Name name, Type type);

	/**
	 * Creates a default boolen constant.
	 * 
	 * @return boolean constant
	 */
	public abstract BooleanConstant createBooleanConstant();

	/**
	 * Creates a default boolen constant.
	 * 
	 * @return boolean constant
	 */
	public abstract CharConstant createCharConstant();

	/**
	 * Creates a default integer constant.
	 * 
	 * @return integer constant
	 */
	public abstract IntegerConstant createIntegerConstant();

	/**
	 * Creates a default nil constant.
	 * 
	 * @return nil constant
	 */
	public abstract Nil createNilConstant();

	/**
	 * Creates a default string constant.
	 * 
	 * @return string constant
	 */
	public abstract StringConstant createStringConstant();

	/**
	 * Creates a formal param.
	 * 
	 * @param name
	 *            name
	 * @return formal par
	 */
	public abstract FormalPar createParam(Name name);

	/**
	 * Creates a name.
	 * 
	 * @param text
	 *            text
	 * @return name
	 */
	public abstract Name createName(String text);

	/**
	 * Gets the last element created.
	 * 
	 * @return last element
	 */
	public abstract ObjectMoon getLastObjectCreated();

	/**
	 * Creates a code fragment.
	 * 
	 * @param beginLine
	 *            begin line
	 * @param beginColumn
	 *            begin column
	 * @param endLine
	 *            end line
	 * @param endColumn
	 *            end column
	 * @param classDef
	 *            class
	 * @param text
	 *            text
	 * @return code fragment
	 */
	public abstract CodeFragment createCodeFragment(int beginLine,
			int beginColumn, int endLine, int endColumn, ClassDef classDef,
			String text);

	/**
	 * Creates a formal parameter.
	 * 
	 * @param name
	 *            name
	 * @return formal parameter
	 */
	public abstract FormalPar createFormalPar(Name name);

	/**
	 * Gets a new parametric type.
	 * 
	 * @param name
	 *            name
	 * @param cd
	 *            class def
	 * @param typeArguments
	 *            type arguments
	 * @return parametric type
	 */
	public abstract Type createParametricType(Name name, ClassDef cd,
			List<Type> typeArguments);
	
	/**
	 * Gets a new attribute with the new type.
	 * 
	 * @param attDec current attribute
	 * @param newType new type of the attribute
	 * @return a new atribute with same data except the new type
	 */
	public abstract AttDec createCopyFromWithType(AttDec attDec, Type newType);
} // MoonFactory
